using System;
using FU.Capstones.IMS.Services.Common.DataContracts;
using FU.Capstones.IMS.Services.Common.Respondents;
using FU.Capstones.IMS.Services.DAOs;
using FU.Capstones.IMS.Services.DataContracts;
using FU.Capstones.IMS.Services.Interfaces;

namespace FU.Capstones.IMS.Services.Management
{
    public class Engine : IEngine
    {
        #region DAOs objects

        private readonly IAccountDAO accountDao = new AccountDAO();
        private readonly IAuthorizationDAO autheticationDao = new AuthorizationDAO();
        private readonly IContactDAO contactDao = new ContactDAO();
        private readonly IEmployeeDAO employeeDao = new EmployeeDAO();
        private readonly IEmploymentTypeDAO employmentTypeDao = new EmploymentTypeDAO();
        private readonly IMaterialDAO materialDao = new MaterialDAO();
        private readonly IOrderDAO orderDao = new OrderDAO();
        private readonly IPartnerDAO partnerDao = new PartnerDAO();
        private readonly IProductDAO productDao = new ProductDAO();
        private readonly IRoleDAO roleDao = new RoleDAO();
        private readonly IWarehouseDAO warehouseDao = new WarehouseDAO();
        private readonly IMaterialLoafDAO materialLoafDAO = new MaterialLoafDAO();

        #endregion

        #region Implementation of IEngine
        
        #region Account

        //public CollectionFeedback<Account> GetAccountCollection(bool isShowAll)
        //{
        //    return accountDao.GetCollection(isShowAll);
        //}

        //public SingleFeedback<Account> GetSingleAccount(int objID)
        //{
        //    return accountDao.GetSingle(objID);
        //}

        //public SingleFeedback<int> InsertAccount(Account data)
        //{
        //    return accountDao.Insert(data);
        //}

        //public Feedback UpdateAccount(Account data)
        //{
        //    return accountDao.Update(data);
        //}

        //public Feedback DeleteAccount(int objID)
        //{
        //    return accountDao.Delete(objID);
        //}

        //public Feedback UndoDeleteAccount(int objID)
        //{
        //    return accountDao.UndoDelete(objID);
        //}

        //public CollectionFeedback<Account> SearchAccount(Account criteria)
        //{
        //    return accountDao.Search(criteria);
        //}

        public SingleFeedback<Account> Login(Account account)
        {
            return accountDao.Login(account);
        }

        public Feedback CheckIfUsernameExists(string usernameToCheck)
        {
            return accountDao.CheckIfUsernameExists(usernameToCheck);
        }

        public Feedback ResetPassword(Account account)
        {
            return accountDao.ResetPassword(account);
        }

        public Feedback ChangePassword(Account account)
        {
            return accountDao.ChangePassword(account);
        }

        #endregion

        #region Authorization

        public CollectionFeedback<Authorization> GetAuthorizationCollection(bool isShowAll)
        {
            return autheticationDao.GetCollection(isShowAll);
        }

        public SingleFeedback<Authorization> GetSingleAuthorization(int objectID)
        {
            return autheticationDao.GetSingle(objectID);
        }

        public SingleFeedback<int> InsertAuthorization(Authorization data)
        {
            return autheticationDao.Insert(data);
        }

        public Feedback UpdateAuthorization(Authorization data)
        {
            return autheticationDao.Update(data);
        }

        public Feedback DeleteAuthorization(int objID)
        {
            return autheticationDao.Delete(objID);
        }

        public CollectionFeedback<Authorization> SearchAuthorization(Authorization criteria)
        {
            return autheticationDao.Search(criteria);
        }

        #endregion

        #region Contact

        public CollectionFeedback<Contact> GetContactCollection(bool isShowAll)
        {
            return contactDao.GetCollection(isShowAll);
        }

        public SingleFeedback<Contact> GetSingleContact(int contactID)
        {
            return contactDao.GetSingle(contactID);
        }

        public SingleFeedback<int> InsertContact(Contact data)
        {
            return contactDao.Insert(data);
        }

        public Feedback UpdateContact(Contact data)
        {
            return contactDao.Update(data);
        }

        public Feedback DeleteContact(int objID)
        {
            return contactDao.Delete(objID);
        }

        public CollectionFeedback<Contact> SearchContact(Contact criteria)
        {
            return contactDao.Search(criteria);
        }

        public Feedback UndoDeleteContact(int objID)
        {
            return contactDao.UndoDelete(objID);
        }


        #endregion

        #region Employee

        public CollectionFeedback<Employee> GetEmployeeCollection(bool isShowAll)
        {
            return employeeDao.GetCollection(isShowAll);
        }

        public SingleFeedback<Employee> GetSingleEmployee(int objectID)
        {
            return employeeDao.GetSingle(objectID);
        }

        public SingleFeedback<int> InsertEmployee(Employee data)
        {
            return employeeDao.Insert(data);
        }

        public Feedback UpdateEmployee(Employee data)
        {
            return employeeDao.Update(data);
        }

        public Feedback DeleteEmployee(int objID)
        {
            return employeeDao.Delete(objID);
        }

        public CollectionFeedback<Employee> SearchEmployee(EmployeeCriteria criteria)
        {
            return employeeDao.Search(criteria);
        }

        public Feedback UndoDeleteEmployee(int objID)
        {
            return employeeDao.UndoDelete(objID);
        }

        #endregion

        #region EmploymentType

        public CollectionFeedback<EmploymentType> GetEmploymentTypeCollection(bool isShowAll)
        {
            return employmentTypeDao.GetCollection(isShowAll);
        }

        public SingleFeedback<EmploymentType> GetSingleEmploymentType(int employmentTypeID)
        {
            return employmentTypeDao.GetSingle(employmentTypeID);
        }

        public SingleFeedback<int> InsertEmploymentType(EmploymentType data)
        {
            return employmentTypeDao.Insert(data);
        }

        public Feedback UpdateEmploymentType(EmploymentType data)
        {
            return employmentTypeDao.Update(data);
        }

        public Feedback DeleteEmploymentType(int objID)
        {
            return employmentTypeDao.Delete(objID);
        }

        public CollectionFeedback<EmploymentType> SearchEmploymentType(EmploymentType criteria)
        {
            return employmentTypeDao.Search(criteria);
        }

        public Feedback UndoDeleteEmploymentType(int objID)
        {
            return employmentTypeDao.UndoDelete(objID);
        }

        #endregion

        #region Material

        public CollectionFeedback<Material> GetMaterialCollection(bool isShowAll)
        {
            return materialDao.GetCollection(isShowAll);
        }

        public CollectionFeedback<Material> GetMaterialCollectionType(bool isShowAll)
        {
            return materialDao.GetCollectionType(isShowAll);
        }


        public SingleFeedback<Material> GetSingleMaterial(int materialID)
        {
            return materialDao.GetSingle(materialID);
        }

        public SingleFeedback<int> InsertMaterial(Material data)
        {
            return materialDao.Insert(data);
        }

        public Feedback UpdateMaterial(Material data)
        {
            return materialDao.Update(data);
        }

        public Feedback DeleteMaterial(int objID)
        {
            return materialDao.Delete(objID);
        }

        public CollectionFeedback<Material> SearchMaterial(Material criteria)
        {
            return materialDao.Search(criteria);
        }

        public Feedback UndoDeleteMaterial(int objID)
        {
            return materialDao.UndoDelete(objID);
        }

        #endregion

        #region Order

        public CollectionFeedback<Order> GetOrderCollection(bool isShowAll)
        {
            return orderDao.GetCollection(isShowAll);
        }
        public CollectionFeedback<Order> GetOrderCollectionByParameter(bool? isMaterial)
        {
            return orderDao.GetOrderCollectionByParameter(isMaterial);
        }

        public SingleFeedback<Order> GetSingleOrder(int orderID)
        {
            return orderDao.GetSingle(orderID);
        }

        public SingleFeedback<int> InsertOrder(Order data)
        {
            return orderDao.Insert(data);
        }

        public Feedback UpdateOrder(Order data)
        {
            return orderDao.Update(data);
        }

        public Feedback DeleteOrder(int objID)
        {
            return orderDao.Delete(objID);
        }

        public CollectionFeedback<Order> SearchOrder(Order criteria)
        {
            return orderDao.Search(criteria);
        }

        public Feedback UndoDeleteOrder(int objID)
        {
            return orderDao.UndoDelete(objID);
        }

        #endregion

        #region Partner

        public CollectionFeedback<Partner> GetPartnerCollection(bool isShowAll)
        {
            return partnerDao.GetCollection(isShowAll);
        }

        public CollectionFeedback<Partner> GetPartnerCollectionByParam(bool? isSupplier)
        {
            return partnerDao.GetCollection2(isSupplier);
        }

        public SingleFeedback<Partner> GetSinglePartner(int partnerID)
        {
            return partnerDao.GetSingle(partnerID);
        }

        public SingleFeedback<int> InsertPartner(Partner data)
        {
            return partnerDao.Insert(data);
        }

        public Feedback UpdatePartner(Partner data)
        {
            return partnerDao.Update(data);
        }

        public Feedback DeletePartner(int objID)
        {
            return partnerDao.Delete(objID);
        }

        public CollectionFeedback<Partner> SearchPartner(Partner criteria)
        {
            return partnerDao.Search(criteria);
        }

        public Feedback UndoDeletePartner(int objID)
        {
            return partnerDao.UndoDelete(objID);
        }

        #endregion

        #region Product

        public CollectionFeedback<Product> GetProductCollection(bool isShowAll)
        {
            return productDao.GetCollection(isShowAll);
        }

        public CollectionFeedback<Product> GetProductCollectionType(bool isShowAll)
        {
            return productDao.GetCollectionType(isShowAll);
        }

        public SingleFeedback<Product> GetSingleProduct(int productID)
        {
            return productDao.GetSingle(productID);
        }

        public SingleFeedback<int> InsertProduct(Product data)
        {
            return productDao.Insert(data);
        }

        public Feedback InsertBuiltupMaterial(int pID, int mID, long mQuantity)
        {
            return productDao.InsertBuiltupMaterial(pID, mID, mQuantity);
        }

        public Feedback UpdateProduct(Product data)
        {
            return productDao.Update(data);
        }

        public Feedback DeleteProduct(int objID)
        {
            return productDao.Delete(objID);
        }

        public Feedback DeleteBuiltup(int pID, int mID)
        {
            return productDao.DeleteBuiltup(pID, mID);
        }

        public CollectionFeedback<Product> SearchProduct(ProductCriteria criteria)
        {
            return productDao.Search(criteria);
        }

        public Feedback UndoDeleteProduct(int objID)
        {
            return productDao.UndoDelete(objID);
        }

        #endregion

        #region Role

        public CollectionFeedback<Role> GetRoleCollection(bool isShowAll)
        {
            return roleDao.GetCollection(isShowAll);
        }

        public SingleFeedback<Role> GetSingleRole(int roleID)
        {
            return roleDao.GetSingle(roleID);
        }

        public SingleFeedback<int> InsertRole(Role data)
        {
            return roleDao.Insert(data);
        }

        public Feedback UpdateRole(Role data)
        {
            return roleDao.Update(data);
        }

        public Feedback DeleteRole(int objID)
        {
            return roleDao.Delete(objID);
        }

        public CollectionFeedback<Role> SearchRole(Role criteria)
        {
            return roleDao.Search(criteria);
        }

        public Feedback UndoDeleteRole(int objID)
        {
            return roleDao.UndoDelete(objID);
        }

        #endregion

        #region Warehouse

        public CollectionFeedback<Warehouse> GetWarehouseCollection(bool isShowAll)
        {
            return warehouseDao.GetCollection(isShowAll);
        }

        public SingleFeedback<Warehouse> GetSingleWarehouse(int warehouseID)
        {
            return warehouseDao.GetSingle(warehouseID);
        }

        public SingleFeedback<int> InsertWarehouse(Warehouse data)
        {
            return warehouseDao.Insert(data);
        }

        public Feedback UpdateWarehouse(Warehouse data)
        {
            return warehouseDao.Update(data);
        }

        public Feedback DeleteWarehouse(int objID)
        {
            return warehouseDao.Delete(objID);
        }

        public CollectionFeedback<Warehouse> SearchWarehouse(Warehouse criteria)
        {
            return warehouseDao.Search(criteria);
        }

        public Feedback UndoDeleteWarehouse(int objID)
        {
            return warehouseDao.UndoDelete(objID);
        }

        #endregion

        #region MaterialLoaf

        public CollectionFeedback<MaterialLoaf> GetMaterialLoafCollection(bool isShowAll)
        {
            return materialLoafDAO.GetCollection(isShowAll);
        }

        public SingleFeedback<MaterialLoaf> GetSingleMaterialLoaf(int materialId)
        {
            return materialLoafDAO.GetSingle(materialId);
        }

        public SingleFeedback<int> InsertMaterialLoaf(MaterialLoaf data)
        {
            return materialLoafDAO.Insert(data);
        }

        public Feedback UpdateMaterialLoaf(MaterialLoaf data)
        {
            return materialLoafDAO.Update(data);
        }
        
        public Feedback DeleteMaterialLoaf(int data)
        {
            return materialLoafDAO.Delete(data);
        }

         public CollectionFeedback<MaterialLoaf> SearchMaterialLoaf(MaterialLoaf criteria)
        {
            return materialLoafDAO.Search(criteria);
        }

         public Feedback UndoDeleteMaterialLoaf(int data)
         {
             return materialLoafDAO.UndoDelete(data);
         }

        #endregion

        #endregion
    }
}
